<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>




<!-- You can start editing here. -->
<!-- If comments are open, but there are no comments. -->
<c:set var="comLen" value="${fn:length(curArticle.comments)}"></c:set>
<c:set var="comments" value="${curArticle.comments}" />

<h3 id="comments">

	<c:choose>
		<c:when test="${comLen<1}">
	No Responses
	</c:when>
		<c:when test="${comLen==1}">
	One Response
	</c:when>
		<c:when test="${comLen>1}">
	${comLen} Responses
	</c:when>
	</c:choose>

	to &ldquo;${curArticle.title }&rdquo;
</h3>
<c:if test="${comLen>0}">
	<ul class="commentlist">
		<c:forEach items="${comments}" var="comment">


			<li class="alt" id="comment-${comment.id }">
				<div class="comment-btm">
					<div class="commenttext">
						${comment.content }
					</div>
					<cite><a href='http://www.myeclipse.com'
						rel='external nofollow' class='url'>${comment.author }</a>
					</cite> on
					<small class="commentmetadata"><a
						href="#comment-${comment.id }" title="">${fn:substring(comment.postTime,0,16)
							}</a> 
					</small>
				</div>
			</li>
		</c:forEach>


	</ul>
</c:if>
<script type="text/javascript">

function checkAuthor(){
	var isCheckOK=true;
     var author=document.getElementById("author").value;
     if(author==''||author==null){
     	alert("姓名不能为空!");
    	isCheckOK=false;
     }else{
         var patrn=/[\<\>\;\,]+/;   
   		if (patrn.exec(author)){ alert("用户名包含非法字符!"); isCheckOK=false;}
		}
		 return isCheckOK;
}

function checkEmail(){
var isCheckOK=true;
	var email=document.getElementById("email").value;
	     if(email==''||email==null){
    	alert("Eamil不能为空!");
    	isCheckOK=false;
     }else{
    	   var patrn=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; 
   			if (!patrn.exec(email)){
   			 alert("Eamil不合法！"); 
   			 isCheckOK=false;
  		}
	}
		return isCheckOK;
}

function checkContent(){
	var comt=document.getElementById("comment").innerHTML;
	if(comt==''||comt==null){ alert("总得说点啥吧？");return false;}
}

function check(){
		if(checkEmail()&&checkAuthor()) return true;
		else return false;
}


</script>
<h3 id="respond">
	Leave a Reply
</h3>
<form
	action="${pageContext.request.contextPath}/blog/comment.do?article_id=${curArticle.id}"
	method="post" id="commentform" onsubmit="return check()">
	<p>
		<input type="text" name="author" id="author" size="22" tabindex="1" onblur="checkAuthor()"/>
		<label for="author">
			<strong>Name</strong> (必须的)
		</label>
	</p>
	<p>
		<input type="text" name="email" id="email" size="22" tabindex="2" onblur="checkEmail()"/>
		<label for="email">
			<strong>Mail</strong> (将不会公布) (必须的)
		</label>
	</p>
	<p>
		<input type="text" name="url" id="url" size="22" tabindex="3" />
		<label for="url">
			<strong>Website</strong>
		</label>
	</p>

	<p>
		<textarea name="content" id="comment" cols="100%" rows="10"
			tabindex="4"></textarea>
	</p>
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/ckeditor/ckeditor.js"></script>
	<script type="text/javascript">
CKEDITOR.replace( 'comment',
    {
       toolbar : 'Basic',
        uiColor : '#9AB8F3'
    });
    </script>
	<p>
		<input name="submit" type="submit" id="submit" tabindex="5"
			value="Submit Comment"/>
		<input type="hidden" name="method" value="addComment" />
	</p>

</form>